/*
 * @Description: 留资信息
 * @Author: 谢涛
 * @Date:   2019-04-22 19:13:58
 * @LastEditTime: 2020-02-28 17:33:37
 * @LastEditors: Please set LastEditors
 */
import React, { Component } from 'react'
import '@ant-design/compatible/assets/index.css';
import {Form, Input, Modal, Col, Row, Select, message, DatePicker, Button, Radio, Tooltip} from 'antd';
import PictureUpload from "@/components/PictureUpload";
import '../../../layouts/handleList.css'
import { institutionsApi, ygxxApi, lzApi, OutsideDoctorApi, userApi } from '@/services/basic'
import moment from 'moment';
import {ButtonLock, SelectCheck, SelectCompanies} from "../../../components/BaseComponent/forms";
import Utils from "../../../utils";

const Option = Select.Option;
class EditItem extends Component {
    constructor(props) {
        super(props);
        this.state = {
            visible: false,
            institutionInitial: [],
            ygxx: [],
            ksid: undefined,
            yybm: undefined,
            yymc: "", //公司名字
            ggbs: true,
            zh: [],
            YHKList: [],
            dgs: [],
            // 计划下拉
            promotes:[],
            // 是否必选
            promotionFlag:false,
            handler: undefined,//当前正在执行的操作类型
            // 联系方式查询到的联系人信息
            // lxrByPhone: null,
            ztbz: null,
            // 用于回显无匹配时
            jhid:null,
            jhmc:null,
            jhList:[],
            // 其他计划，避免对原options污染，
            // 否则会出现奇怪的bug，改都不知道在哪改！！！！！
            otherPlan: null
        }
    }

    //弹出操作页面
    showModal = (handler, record) => {
        this.setState({
            // lxrByPhone:null,
            ygxx:[],
            YHKList: [],
            jhList:[],
            jhmc:null,
            jhid:null
        });
        if(handler !== "create") {
            // const params = { zw: 6}
            ygxxApi.search({}).then((res) => {
                let ygxx = res.records.map((item) => (
                    <Option key={item.gh} value={item.gh} label={item.xm}>
                        {item.xm}（{item.slzt}）
                    </Option>
                ));
                // this.form.setFieldsValue({ lxr: res.records[0].gh })
                this.setState({
                    ygxx: ygxx,
                });
            });
        }

        ygxxApi.search({ zw: 3 }).then((res) => {
            let dgs = res.records.map((item) => (
                <Option key={item.gh} value={item.gh}>
                    {item.xm}
                </Option>
            ));
            this.setState({
                dgs: dgs,
            });
        });

        if (record) {//如果有record传过来 说明一定是查看或者更新操作
            const { lzid } = record;
            this.setState({ visible: true, lzid, handler })
            this.handleView(lzid);
        } else {//如果是新增操作 那直接展示弹出框 赋值操作类型
            this.setState({ visible: true, handler }, () => {
                // const { yybm, yymc } = JSON.parse(sessionStorage.getItem('userInfo'))
                // this.form && this.form.setFieldsValue({ yybm: yybm })
                // this.setState({
                //   institutionInitial: <Option key={yymc} value={yybm}>{yymc}</Option>
                // })

                let sfsj = new Date()
                this.form.setFieldsValue({ lzrq: moment(sfsj),gjzt:1 })
            })


            institutionsApi.search({ search: `` }).then((res) => {
                let institutionInitial = res.records.map((item) => (
                    <Option key={item.yybm} value={item.yybm}>
                        {item.yymc}
                    </Option>
                ));
                this.setState({
                    institutionInitial: institutionInitial,
                });
            });
        }
    }

    //关闭操作页面
    hideModal = (cb) => {
        this.setState({
                visible: false,
                institutionInitial: [],
                ksid: undefined,
                yybm: undefined,
                ggbs: true,
                handler: undefined,//当前正在执行的操作类型
            }, () => {
                this.form.resetFields()
                if (cb) cb();
            }
        )
    }

    //Modal框自带的取消操作
    handleCancel = () => {
        this.hideModal();
    }

    //Modal框自带的确认操作
    handleOk = () => {
        return new Promise((resolve, reject)=>{
            this.form.validateFields().then(() => {
                let newItem = this.form.getFieldsValue();
                const { handler, id, YHKList, lyzhmc, ztbz } = this.state
                const requestType = handler === 'create' ? 'post' : 'put'
                newItem.id = id;
                newItem.ztbz = ztbz;
                newItem.yhkzp = YHKList.length > 0 ? YHKList[0].url : "";
                newItem.lzrq = newItem.lzrq && moment(newItem.lzrq).format("YYYY-MM-DD hh:mm:ss");
                newItem.jdrq = newItem.jdrq && moment(newItem.jdrq).format("YYYY-MM-DD hh:mm:ss");
                newItem.yyrq = newItem.yyrq && moment(newItem.yyrq).format("YYYY-MM-DD hh:mm:ss");
                newItem.cjrq = newItem.cjrq && moment(newItem.cjrq).format("YYYY-MM-DD hh:mm:ss");
                newItem.lyzhmc = lyzhmc;
                newItem.jhid = this.state.jhid
                newItem.jhmc = newItem.jhmc || newItem.jhid
                // 跟进状态：6-到店已成交，11-异公司已成交
                if(newItem.gjzt === 6) {
                    newItem.yymc = this.state.yymc
                }else if(newItem.gjzt === 11) {
                }

                lzApi[requestType](newItem)
                    .then((response) => {
                        if (response.code === '1') {
                            // 先关闭弹窗，再回调解锁按钮
                            this.hideModal(()=>{
                                resolve();
                            });
                            this.props.editItemDone();
                            message.success('操作成功');
                        } else {
                            message.error(`操作失败 ${response.msg}`);
                            reject();
                        }
                    }).catch(()=>{
                    reject();
                })
            })
                .catch(error => {
                    // eslint-disable-next-line
                    console.dir(error)
                    reject();
                })
        })

    }

    onRadioChange = (e) => {
        this.setState({
            radioValue: e.target.value,
        });
    }
    gjztchangeColumn = (e) => {
        // this.setState({
        //   gjzt: e.target.value,
        // });
    }

    //公司机构输入时触发
    onInstitutionSearch = (value) => {
        if (value.charCodeAt(value.length - 1) === 32) {
            value = value.trim();
            institutionsApi.search({ search: `${value}` }).then((res) => {
                let institutionInitial = res.records.map((item) => (
                    <Option key={item.yybm} value={item.yybm}>
                        {item.yymc}
                    </Option>
                ));
                this.setState({
                    institutionInitial: institutionInitial,
                });
            });
        }
    };

    // 公司选项改变时
    onInstitutionChange = (_, e)=>{
        this.setState({
            yymc: e.children
        })
        // this.form.resetFields(['lxr']);
        // this.onygxxSearch();
        this.searchCf();
    }

    // 联系方式校验
    lxfsBlur = (e) => {
        const text = e.target.value;
        const value = text.replace(/\s+/g, "");
        this.form.setFieldsValue({
            lxfs: value, // 设置新的值
        });

        if(!value) return;
        this.searchCf(value);
        const msg = Utils.checkTelephone(value);
        // const regex = /^(13[0-9]|14[5-9]|15[0-9]|16[2-9]|17[0-9]|18[0-9]|19[0-9])\d{8}$/;
        message.info(msg || "联系方式不符合手机号")
    }

    searchCf = () => {
        if(this.state.handler !== "create") return;
        const clear = () => {
            this.setState({
                // lxrByPhone: null,
                ygxx: [],
                ztbz: null
            })
            this.form.setFieldsValue({"lxr":null})
        }
        const lyzh  = this.form.getFieldsValue().lyzh;
        const yxxm  = this.form.getFieldsValue().yxxm;
        const lxfs  = this.form.getFieldsValue().lxfs;
        const yybm  = this.form.getFieldsValue().yybm;

        if (!lyzh || !yxxm || !lxfs || !yybm) {
            clear();
            return;
        }
        // if(lxfs.includes("二维码") || lxfs.includes("客户加")) {
        //   clear();
        //   return;
        // }
        ygxxApi.searchCf({lyzh,yxxm,lxfs,yybm}).then(res => {
            if (res.code === "1") {
                if (res.data) {
                    const ygxx = (
                        <Option key={res.data.gh} value={res.data.gh}>
                            {res.data.xm}（{res.data.slzt || 0}）
                        </Option>
                    )
                    this.setState({
                        // lxrByPhone: res.data,
                        ygxx,
                        jhid: res.data.jhid,
                        jhmc: res.data.jhmc,
                    }, () => {
                        this.findJhmc()
                    })
                    this.form.setFieldsValue({
                        lxr: res.data.gh
                    });
                } else {
                    clear();
                }
            } else {
                // 当天不可重复
                // 2-7天重复给同一人
                // 7天以上不算重复
                console.error(res.msg)
                clear();
                // this.setState({lxrByPhone:true})
                // 当天同账号联系方式已存在
                message.warn(res.msg || "未知错误");
            }
        }).catch(err => {
            console.error(err);
            clear();
        })
    }

    //账号输入时触发
    onZhSearch = (value) => {
        if (value.charCodeAt(value.length - 1) === 32) {
            value = value.trim();
            OutsideDoctorApi.search({ hzxm: `${value}` }).then((res) => {
                let zh = res.records.map((item) => (
                    <Option key={item.sfzh} value={item.sfzh}>
                        {item.hzxm}
                    </Option>
                ));
                this.setState({
                    zh: zh,
                });
            });
        }
    };

    // 选择：来源账号
    onZhChange = (_,e) => {
        this.setState({
            lyzhmc:e.children
        })
        this.searchCf();
        this.getPromotes(e.value)
    }

    // 客服/销售 聚焦
    onygxxFocus = ()=>  {
        const lxr = this.form.getFieldsValue().lxr || "";
        // const obj = this.state.lxrByPhone;
        // if(obj) {
        //   if(obj === true) {
        //     message.warn("当天同账号联系方式已存在");
        //   }
        //   return;
        // }
        if(!lxr) this.onygxxSearch();
    }
    //人员输入时触发
    onygxxSearch = (value = " ") => {
        // if(this.state.lxrByPhone) {
        //   message.info("该联系方式已有联系人："+this.state.lxrByPhone.xm);
        //   return;
        // }
        if (value.charCodeAt(value.length - 1) === 32) {
            value = value.trim();

            const params = {
                search:value,
                sfzx:1
            }
            /*      // if (yybm === "33060000000000033") {
                  //   // 公司名称：杭州旗舰店  33060000000000033
                  //   delete params.yybm;
                  //   delete params.zw;
                  // } else
                    if (["66261811352", "98551941147"].includes(lyzh)) {
                    // 来源账号
                    // 66261811352 鹏成车邦｜总部座椅通风
                    // 98551941147 鹏成车邦总部·360全景
                    params.zw = 6;
                    delete params.yybm;
                  } else if (yybm === "33060000000000045") {
                    // 33060000000000045 其他
                    delete params.yybm;
                  }*/
            // const ygxxSearch = this.state.handler === "create" ? ygxxApi.newSearch : ygxxApi.search;
            // if (this.state.handler === "create") params.lyzh = lyzh;// 来源账号
            ygxxApi.search(params).then((res) => {
                let ygxx = res.records.map((item) => (
                    <Option key={item.gh} value={item.gh}>
                        {item.xm}（{item.slzt}）
                    </Option>
                ));
                this.setState({
                    ygxx: ygxx,
                });
                if(this.state.handler === "create") this.form.setFieldsValue({ lxr: res.records[0]?res.records[0].gh:null })
            });
        }
    };
    //用户组获取焦点时回调
    // getUsergroup = () => {
    //     userGroupApi.getSelectOption({})
    //         .then((res) => {
    //             if (res.records && res.records.length !== 0) {
    //                 const UserGroup = res.records.map(item => <Option key={item.id} value={item.id}>{item.yhzmc}</Option>);
    //                 this.setState({ UserGroup })
    //             }
    //         })
    // }

    //人员输入时触发
    onyhSearch = (value) => {
        userApi.get(value).then((res) => {
            const { id, yhxm } = { ...res.data }
            this.setState({
                yh: <Option value={id} key={id}>{yhxm}</Option>
            });
        });

    };
    //导购输入时触发
    onygxxSearch1 = (value) => {
        if (value.charCodeAt(value.length - 1) === 32) {
            value = value.trim();
            ygxxApi.search({ search: `${value}`, zw: 3 }).then((res) => {
                let dgs = res.records.map((item) => (
                    <Option key={item.gh} value={item.gh}>
                        {item.xm}
                    </Option>
                ));
                this.setState({
                    dgs: dgs,
                });
            });
        }
    };
    //查看单条
    handleView = (id) => {
        this.setState({ visible: true })
        lzApi.get(id)
            .then((res) => {
                if(res.code !== "1") {
                    const msg = res.msg && res.msg.length < 100 ? res.msg : "未知错误"
                    message.error(msg);
                    return;
                }
                const { yyid } = JSON.parse(sessionStorage.getItem('userInfo'))
                const { id, cx, qy, lxfs, yxxm, lxly, gjzt, lzrq, lzbh, yybm, yymc, bz,lzid, lyzh, hzxm, lxr, yyrq, yyxm, cjje, cjrq, dg, jdrq, sgxm, gjqk, cjrid, jz,ygs,jhid,jhmc,zfyy,ztbz,shbz,zjz } = res.data;
                this.setState({yymc,jhid,jhmc,ztbz})
                let { yhkzp } = res.data
                const institutionInitial = <Option key={yybm} value={yybm} >{yymc}</Option>;
                const zh = <Option key={lyzh} value={lyzh} >{hzxm}</Option>;
                // const ygxx = <Option key={lxr} value={lxr} >{hzxm}</Option>;
                // const dgs = <Option key={dg} value={lxr} >{hzxm}</Option>;
                if (yhkzp) {
                    this.setState({
                        YHKList: [
                            {
                                uid: 1,
                                name: "image.png",
                                status: "done",
                                url: yhkzp,
                            },
                        ],

                    });
                }
                this.setState({
                    institutionInitial,
                    yybm: yybm,
                    zh: zh,
                    id: id,
                    gjzt: gjzt,
                    yxxm: yxxm,
                    jz,
                    shbz
                })
                this.form.setFieldsValue({ id, cx, qy, lxfs, yxxm, lxly, gjzt, bz,lzrq: lzrq && moment(lzrq), lzbh, yybm, yymc, lzid, sgxm, lyzh, hzxm, gjqk, cjrid, lxr, yyrq: yyrq && moment(yyrq), yyxm, cjje, cjrq: cjrq && moment(cjrq), jdrq: jdrq && moment(jdrq), dg, jz,ygs,jhid,zfyy,zjz } )
                if (yyid !== 0) this.form.setFieldsValue({ yybm })
                this.onyhSearch(cjrid);
                this.getPromotes(lyzh)
            })
    }
    onRankChange = (value) => {//监听级别的变化 重要
        this.setState({ gjzt: value })
        // this.form.resetFields(['dqdm']);
    }
    onRankyxxmChange = (value) => {//监听级别的变化 重要
        this.setState({ yxxm: value })
        // this.form.resetFields(['dqdm']);
        this.searchCf();
    }

    promotionSearch = (value) => {
        this.setOtherPlan(value)
    }

    // onChange
    promoteChange = (jhid) =>{
        this.setState({jhid})
    }

    // onFocus
    onPromotionFocus = () => {
        const {lyzh} = this.form.getFieldsValue()
        if (!lyzh) {
            message.warning("请先选择来源账号");
        } else if (!this.state.promotionFlag) {
            message.info("该账号无可选计划");
            this.getPromotes(lyzh)
        }
    }
    // 计划下拉
    getPromotes(lyzh) {
        ygxxApi.getPromotes({lyzh,ztbz:1,size:10000}).then((res) => {
            const list = res.records
            // 后台没有限制jhid去重，会导致label全显示成重复的哪个，改用key=id
            const promotes = list.map((item) => (
                <Option key={item.id} value={item.jhid}>
                    {item.jhmc}
                </Option>
            ));

            this.setState({
                promotes,
                jhList: list,
                promotionFlag: !!res.total
            }, () => {
                this.setOtherPlan(this.state.jhid)
            });
        });
    }
    // 判断计划名称
    findJhmc() {
        console.log("---")
        return;
        const form = this.form.getFieldsValue()
        const i = this.state.jhList.findIndex(item=>{
            return item.jhid ===  form.jhid
        })
        // console.log("----")
        // console.log(form)
        // console.log(this.state.jhList)
        // console.log(this.state.jhid,this.state.jhmc)
        if (i < 0) {
            this.form.setFieldsValue({jhid: this.state.jhmc})
        }
    }

    // 设置其他选项
    setOtherPlan(value) {
        const list = this.state.jhList
        let otherPlan = null
        const search = value ?value.trim():''
        // 如果手动输入的19位数字，且接口里返回的没有匹配
        if (/^\d{19}$/.test(search) && list.findIndex(o => o.jhid === search) < 0) {
            otherPlan = <Option key={search} value={search}>{search}(手动输入计划编号)</Option>
        }
        this.setState({otherPlan})
    }

    jhFilter(input, option) {
        return (option.value && option.value.includes(input)) || (option.children && option.children.includes(input))
    }
    render() {
        const { handler, YHKList, promotionFlag,ztbz} = this.state;
        // const { yyid } = JSON.parse(sessionStorage.getItem('userInfo'))
        return (
            <div className='handle-header'>
                <Modal
                    title=""
                    visible={this.state.visible}
                    onOk={this.handleOk}
                    onCancel={this.handleCancel}
                    width="460px"
                    style={{ top: 120 }}
                    maskClosable={false}
                    className="handleList"
                    footer={this.state.handler === "view" ? null : [
                        <Button onClick={this.handleCancel}>取消</Button>,
                        <ButtonLock onClick={this.handleOk} type="primary">确定</ButtonLock>
                    ]}
                >
                    <div className="formHeader">
                        <span className='handle-title'>{`${handler === 'view' ? '查看' : handler === 'create' ? '新增' : '更新'}留资`}</span>
                    </div>
                    <Form autoComplete="off" onSubmit={this.handleOk} ref={form => this.form = form}  >
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='来源账号' className="lyzh"
                                           name="lyzh"
                                           disabled={handler === 'view' || handler === "update"}
                                           rules={[{ required: 'true', message: '此为必填项' }]}
                                >
                                    <Select
                                        onSearch={this.onZhSearch}
                                        onChange={this.onZhChange}
                                        placeholder="请选择账号"
                                        filterOption={false}
                                        showSearch={true}
                                        showArrow={false}
                                    >
                                        {this.state.zh}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='公司名称'
                                           name="yybm"
                                           rules={[{ required: 'true', message: '此为必填项' }]}
                                >
                                    <Select
                                        onSearch={this.onInstitutionSearch}
                                        onChange={this.onInstitutionChange}
                                        placeholder="请选择公司"
                                        filterOption={false}
                                        showSearch={true}
                                        showArrow={false}
                                    >
                                        {this.state.institutionInitial}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            {/* <Col span={24}>
                <Form.Item label='类型'
                    name="lx"
                    rules={[{ required: 'true', message: '此为必填项' }]}
                >
                    <Select
                      allowClear={handler === 'view' ? false : true}
                      // disabled={handler === 'create' ? false : true}
                      placeholder="请选类型"
                      filterOption={false}
                      showSearch={true}
                    // onChange={this.officeTypeChange}
                    >
                      {
                          this.props.bookRender('kslx',false)
                      }
                    </Select>
                </Form.Item>
              </Col> */}
                        </Row>

                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='意向项目' className="yxxm"
                                           name="yxxm"
                                           rules={[{ required: 'true', message: '此为必填项' }]}

                                >
                                    {/* <Input
                    disabled={handler === 'view' ? true : false}
                    allowClear={handler === 'view' ? false : true}
                    placeholder="请输入" /> */}
                                    <Select
                                        placeholder="请选择意向项目"
                                        onChange={this.onRankyxxmChange}>
                                        {this.props.bookRender("yxxm")}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>

                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='联系方式'
                                           name="lxfs"
                                           rules={[{ required: 'true', message: '此为必填项' }]}
                                >
                                    <Input
                                        disabled={handler === 'view' || handler === "update"}
                                        allowClear={handler === 'create'}
                                        // onBlur={this.lxfsChange}
                                        onBlur={this.lxfsBlur}
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>

                        {/*              <Row gutter={8} >
                <InputPhoneNumber required={true} colSpan={24}></InputPhoneNumber>
              </Row>*/}

                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='车型'
                                           name="cx"
                                           getValueFromEvent={event => event.target.value.replace(/\s+/g, "")}
                                           rules={[{ required: 'true', message: '此为必填项' }]}
                                >
                                    <Input
                                        disabled={handler === 'view'}
                                        allowClear={handler !== 'view'}
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='区域' className="qy"
                                           name="qy"
                                           getValueFromEvent={event => event.target.value.replace(/\s+/g, "")}
                                           rules={[{ required: 'true', message: '此为必填项' }]}

                                >
                                    <Input
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>

                        <Row gutter={8}  style={{ display: this.state.handler==="update" ? 'block' : 'none' }}>
                            <Col span={24}>
                                <Form.Item label='创建人' className="cjrid"
                                           name="cjrid"
                                >
                                    <Select
                                        disabled
                                        onSearch={this.onyhSearch}
                                        placeholder="请选择人员"
                                        filterOption={false}
                                        showSearch={true}
                                        showArrow={false}
                                    >
                                        {this.state.yh}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>

                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item
                                    label='客服/销售'
                                    className="lxr"
                                    name="lxr"
                                    rules={[{required: 'true', message: '此为必填项'}]}
                                >
                                    <Select
                                        onSearch={this.onygxxSearch}
                                        onFocus={this.onygxxFocus}
                                        placeholder="请选择人员"
                                        filterOption={false}
                                        showSearch={true}
                                        showArrow={false}
                                    >
                                        {this.state.ygxx}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>

                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='联系来源' className="lxly"
                                           name="lxly"
                                           rules={[{ required: 'true', message: '此为必填项' }]}

                                >
                                    <Select allowClear placeholder="请选择联系来源">
                                        {this.props.bookRender("lxly")}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='跟进状态' className="gjzt"
                                           name="gjzt"
                                           rules={[{ required: 'true', message: '此为必填项' }]}
                                >
                                    <Select placeholder="请选择跟进状态"
                                            onChange={this.onRankChange}>
                                        {this.props.bookRender("gjzt")}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>
                        {
                            this.state.gjzt === 10|| this.state.gjzt === 11 ? (
                                <Row gutter={8}><SelectCompanies colSpan={24} label="实际公司" keyword="ygs"
                                                                 rules={[{required: true, message: '异公司到店/已成交，需要选择实际公司'}]}
                                ></SelectCompanies></Row>) : null
                        }
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='留资日期' className="lzrq"
                                           name="lzrq"
                                           rules={[{ required: 'true', message: '此为必填项' }]}

                                >
                                    <DatePicker format={"YYYY-MM-DD"} />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item
                                    label='计划名称'
                                    name="jhid"
                                    rules={
                                        handler === 'create' && promotionFlag ? [{required: 'true', message: '此为必填项'}] : []
                                    }
                                >
                                    <Select
                                        onFocus={this.onPromotionFocus}
                                        onSearch={this.promotionSearch}
                                        onChange={this.promoteChange}
                                        placeholder="请选择计划名称"
                                        // filterOption={false}
                                        showSearch={true}
                                        showArrow={false}
                                        filterOption={this.jhFilter}
                                    >
                                        {this.state.otherPlan}
                                        {this.state.promotes}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>

                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='预约日期' className="yyrq"
                                           name="yyrq"
                                           rules={[{ required: this.state.gjzt === 3 ? true : false, message: '预约需填写预约日期' }]}
                                >
                                    <DatePicker format={"YYYY-MM-DD"} />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='跟进情况' className="gjqk"
                                           name="gjqk"
                                >
                                    <Input
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='备注' className="bz"
                                           name="bz"
                                           rules={[{ required: this.state.yxxm === 6? true : false, message: '其他意向项目必须填' }]}

                                >
                                    <Input
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='预约项目'
                                           name="yyxm"
                                           rules={[{ required: this.state.gjzt === 3 ? true : false, message: '预约需填写预约项目' }]}
                                >
                                    <Input
                                        disabled={handler === 'view' ? true : false}
                                        allowClear={handler === 'view' ? false : true}
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >

                            <Col span={24}>
                                <Form.Item label='导购' className="dg"
                                           name="dg"
                                           rules={[{ required: this.state.gjzt === 6 ? true : false, message: '到店已成交，需要填导购' }]}

                                >
                                    <Select
                                        onSearch={this.onygxxSearch1}
                                        placeholder="请选择人员"
                                        filterOption={false}
                                        showSearch={true}
                                        showArrow={false}
                                    >
                                        {this.state.dgs}
                                    </Select>
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='成交金额'
                                           name="cjje"
                                           rules={[{ required: this.state.gjzt === 6 ? true : false, message: '到店已成交成交，需要成交金额' }]}
                                >
                                    <Input
                                        disabled={handler === 'view' ? true : false}
                                        allowClear={handler === 'view' ? false : true}
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='增减值'
                                           name="zjz"
                                >
                                    <Input
                                        disabled={handler === 'view' ? true : false}
                                        allowClear={handler === 'view' ? false : true}
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='施工项目'
                                           name="sgxm"
                                           rules={[{ required: this.state.gjzt === 6 ? true : false, message: '到店已成交成交，需要施工项目' }]}
                                >
                                    <Input
                                        disabled={handler === 'view' ? true : false}
                                        allowClear={handler === 'view' ? false : true}
                                        placeholder="请输入" />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='成交日期' className="cjrq"
                                           name="cjrq"
                                           rules={[{ required: this.state.gjzt === 6 ? true : false, message: '到店已成交成交，需要成交日期' }]}

                                >
                                    <DatePicker format={"YYYY-MM-DD"} />
                                </Form.Item>
                            </Col>
                        </Row>
                        <Row gutter={8} >
                            <Col span={24}>
                                <Form.Item label='进店日期' className="jdrq"
                                           name="jdrq"
                                           rules={[{ required: this.state.gjzt === 6 || this.state.gjzt === 5 ? true : false, message: '到店已成交成交，需要填到店日期' }]}
                                >
                                    <DatePicker format={"YYYY-MM-DD"} />
                                </Form.Item>
                            </Col>
                        </Row>

                        {/*<Row gutter={8} >*/}
                        {/*  <SelectCheck permission={true} colSpan={24}></SelectCheck>*/}
                        {/*</Row>*/}
                        {
                            ztbz ? null : <Row gutter={8}>
                                <Col span={24}>
                                    <Form.Item label='作废原因' name="zfyy">
                                        <Input placeholder="请输入作废原因" disabled></Input>
                                    </Form.Item>
                                </Col>
                            </Row>
                        }

                        {handler === "create" ? null : (<>
                            <Row gutter={8}>
                                <Col span={24}>
                                    <Form.Item label='审核状态'>
                                        <Select disabled placeholder="审核状态" value={this.state.jz}>
                                            <Option value={0}>未核对</Option>
                                            <Option value={1}>已核对</Option>
                                            <Option value={2}>核对有误</Option>
                                        </Select>
                                    </Form.Item>
                                </Col>
                            </Row>

                            <Row gutter={8}>
                                <Col span={24}>
                                    <Form.Item label='审核备注'>
                                        <Input disabled value={this.state.shbz}/>
                                    </Form.Item>
                                </Col>
                            </Row>
                        </>)}

                        <Row gutter={8}>
                            <Col span={10}>
                                <Form.Item label="二维码" name="yhkzp">
                                    <PictureUpload
                                        fileList={YHKList}
                                        Leng={1}
                                        // disabled={handler === "view"}
                                        onChange={(YHKList) => {
                                            this.setState({
                                                YHKList: YHKList,
                                            });
                                        }}
                                    />
                                    {/* <Button type="primary" onClick={() => this.upload("yhk")}>拍照上传</Button> */}
                                </Form.Item>
                            </Col>
                        </Row>
                    </Form>
                </Modal>
            </div>
        );
    }
}
export default EditItem;